<?php

class raw_address extends entity
{
    public $structs = [
        'number' => '',
        'person_name' => '',
        'person_mobile_number' => '',
        'estate_name' => '',
        'house_address' => '',
        'status' => '',
        'snap_formated_address_string' => '',
        'upload_batch_id' => '',
    ];

    public static $entity_display_name = '原始地址';
    public static $entity_description = '原始地址';

    public static $struct_types = [
        'number' => 'text',
        'person_name' => 'text',
        'person_mobile_number' => 'text',
        'estate_name' => 'text',
        'house_address' => 'text',
        'status' => 'enum',
        'snap_formated_address_string' => 'text',
        'upload_batch_id' => 'number',
    ];

    public static $struct_display_names = [
        'number' => '序号',
        'person_name' => '收货人姓名',
        'person_mobile_number' => '收货人手机号',
        'estate_name' => '小区名',
        'house_address' => '细节地址',
        'status' => '地址状态',
        'snap_formated_address_string' => '最终识别后的地址',
        'upload_batch_id' => '上传批次ID',
    ];

    public static $struct_descriptions = [
        'number' => '序号',
        'person_name' => '收货人姓名',
        'person_mobile_number' => '收货人手机号',
        'estate_name' => '小区名',
        'house_address' => '细节地址',
        'status' => '地址状态',
        'snap_formated_address_string' => '最终识别后的地址',
        'upload_batch_id' => '上传批次ID',
    ];

    const STATUS_INIT = 'INIT';
    const STATUS_NOT_FOUND = 'NOT_FOUND';
    const STATUS_NOT_COMPLETE = 'NOT_COMPLETE';
    const STATUS_FORMATED = 'FORMATED';
    const STATUS_INVALID = 'INVALID';

    const STATUS_MAPS = [
        self::STATUS_INIT => '初始化',
        self::STATUS_NOT_FOUND => '未识别',
        self::STATUS_NOT_COMPLETE => '不完整',
        self::STATUS_FORMATED => '已格式化',
        self::STATUS_INVALID => '无效地址',
    ];

    public static $struct_formats = [
        'status' => self::STATUS_MAPS,
    ];

    public static $struct_format_descriptions = [
        'status' => '',
    ];

    public function __construct()
    {/*{{{*/
        $this->belongs_to('upload_batch');
    }/*}}}*/

    public static function create()
    {/*{{{*/
        return parent::init();
    }/*}}}*/

    public function get_status_description()
    {/*{{{*/
        return self::STATUS_MAPS[$this->status];
    }/*}}}*/

    public function set_status_init()
    {/*{{{*/
        $this->status = self::STATUS_INIT;
    }/*}}}*/

    public function status_is_init()
    {/*{{{*/
        return $this->status === self::STATUS_INIT;
    }/*}}}*/

    public function set_status_not_found()
    {/*{{{*/
        $this->status = self::STATUS_NOT_FOUND;
    }/*}}}*/

    public function status_is_not_found()
    {/*{{{*/
        return $this->status === self::STATUS_NOT_FOUND;
    }/*}}}*/

    public function set_status_not_complete()
    {/*{{{*/
        $this->status = self::STATUS_NOT_COMPLETE;
    }/*}}}*/

    public function status_is_not_complete()
    {/*{{{*/
        return $this->status === self::STATUS_NOT_COMPLETE;
    }/*}}}*/

    public function set_status_formated()
    {/*{{{*/
        $this->status = self::STATUS_FORMATED;
    }/*}}}*/

    public function status_is_formated()
    {/*{{{*/
        return $this->status === self::STATUS_FORMATED;
    }/*}}}*/

    public function set_status_invalid()
    {/*{{{*/
        $this->status = self::STATUS_INVALID;
    }/*}}}*/

    public function status_is_invalid()
    {/*{{{*/
        return $this->status === self::STATUS_INVALID;
    }/*}}}*/
}
